using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace phasor
{
	/// <summary>
	/// Summary description for ZoomForm.
	/// </summary>
	public class ZoomForm : System.Windows.Forms.Form {

		private System.Windows.Forms.Label label4;
		internal System.Windows.Forms.TrackBar trackZoom;

		private System.ComponentModel.Container components = null;

		
		
		public Form1 form1;
		public bool Closed;

		private bool trackZoomJustSet = false;

		public ZoomForm() {

			InitializeComponent();

		}

		protected override bool ProcessDialogKey(Keys key) {
			return form1.ProcessDialogKey_Internal(key);
		}

		#region Generated Code
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label4 = new System.Windows.Forms.Label();
			this.trackZoom = new System.Windows.Forms.TrackBar();
			((System.ComponentModel.ISupportInitialize)(this.trackZoom)).BeginInit();
			this.SuspendLayout();
			// 
			// label4
			// 
			this.label4.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label4.Location = new System.Drawing.Point(0, 2);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(40, 16);
			this.label4.TabIndex = 25;
			this.label4.Text = "Zoom:";
			// 
			// trackZoom
			// 
			this.trackZoom.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left)));
			this.trackZoom.AutoSize = false;
			this.trackZoom.LargeChange = 1;
			this.trackZoom.Location = new System.Drawing.Point(6, 16);
			this.trackZoom.Maximum = 1000;
			this.trackZoom.Minimum = -1000;
			this.trackZoom.Name = "trackZoom";
			this.trackZoom.Orientation = System.Windows.Forms.Orientation.Vertical;
			this.trackZoom.Size = new System.Drawing.Size(30, 202);
			this.trackZoom.TabIndex = 24;
			this.trackZoom.TickStyle = System.Windows.Forms.TickStyle.None;
			this.trackZoom.KeyDown += new System.Windows.Forms.KeyEventHandler(this.trackZoom_KeyDown);
			this.trackZoom.ValueChanged += new System.EventHandler(this.trackZoom_ValueChanged);
			// 
			// ZoomForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.White;
			this.ClientSize = new System.Drawing.Size(36, 216);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.trackZoom);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Name = "ZoomForm";
			this.Opacity = 0.25;
			this.ShowInTaskbar = false;
			this.Text = "ZoomForm";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.ZoomForm_Closing);
			this.Load += new System.EventHandler(this.ZoomForm_Load);
			((System.ComponentModel.ISupportInitialize)(this.trackZoom)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		#endregion
		
		public void SetPositionOnOwner() {
			this.Location = form1.PointToScreen(new Point(120, 260));
			this.Height = form1.ClientRectangle.Height - 260 - 11;
		}
		
		private void ZoomForm_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
			Closed = true;
		}

		private void ZoomForm_Load(object sender, System.EventArgs e) {
			SetPositionOnOwner();
			this.Width = 36;

		}

		private void trackZoom_ValueChanged(object sender, System.EventArgs e) {
			if (!trackZoomJustSet) {
				form1.graph1.SetScaleFromLinear(trackZoom.Value);
			} else {
				trackZoomJustSet = false;
			}
		}


		private void trackZoom_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) {
			e.Handled = ProcessDialogKey(e.KeyCode);
		}
	}
}
